package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.system.mapper.ExamAnswerMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ExamQuestionMapper;
import com.ruoyi.system.domain.ExamQuestion;
import com.ruoyi.system.service.IExamQuestionService;

/**
 * 试卷题目Service业务层处理
 *
 * @author tyro
 * @date 2025-05-21
 */
@Service
public class ExamQuestionServiceImpl implements IExamQuestionService
{
    @Autowired
    private ExamQuestionMapper examQuestionMapper;

    @Autowired
    private ExamAnswerMapper  examAnswerMapper;
    /**
     * 查询试卷题目
     *
     * @param id 试卷题目主键
     * @return 试卷题目
     */
    @Override
    public ExamQuestion selectExamQuestionById(Long id)
    {
        return examQuestionMapper.selectExamQuestionById(id);
    }

    /**
     * 查询试卷题目列表
     *
     * @param examQuestion 试卷题目
     * @return 试卷题目
     */
    @Override
    public List<ExamQuestion> selectExamQuestionList(ExamQuestion examQuestion)
    {
        return examQuestionMapper.selectExamQuestionList(examQuestion);
    }

    /**
     * 新增试卷题目
     *
     * @param examQuestion 试卷题目
     * @return 结果
     */
    @Override
    public int insertExamQuestion(ExamQuestion examQuestion)
    {
        return examQuestionMapper.insertExamQuestion(examQuestion);
    }

    /**
     * 修改试卷题目
     *
     * @param examQuestion 试卷题目
     * @return 结果
     */
    @Override
    public int updateExamQuestion(ExamQuestion examQuestion)
    {
        return examQuestionMapper.updateExamQuestion(examQuestion);
    }

    /**
     * 批量删除试卷题目
     *
     * @param ids 需要删除的试卷题目主键
     * @return 结果
     */
    @Override
    public int deleteExamQuestionByIds(Long[] ids)
    {
        // 先删除这些问题对应的答案
        examAnswerMapper.deleteExamAnswerByQuestionIds(ids);

        // 再删除问题
        return examQuestionMapper.deleteExamQuestionByIds(ids);
    }

    /**
     * 删除试卷题目信息
     *
     * @param id 试卷题目主键
     * @return 结果
     */
    @Override
    public int deleteExamQuestionById(Long id)
    {
        return examQuestionMapper.deleteExamQuestionById(id);
    }
}
